﻿using System.Collections.Generic;

namespace BitworkStudios.Web.Mvc.Framework.Navigation
{
    public class MenuItemNode
    {
        public MenuItemNode ParentNode { get; set; }
        public List<MenuItemNode> ChildNodes { get; set; }

        public string Title { get; set; }
        private bool _isActive;

        public bool IsActive
        {
            get { return _isActive; }
            set
            {
                _isActive = value;

                if (ChildNodes.Count > 0 && value == false)
                {
                    foreach (MenuItemNode menuItemNode in ChildNodes)
                    {
                        menuItemNode.IsActive = false;
                    }
                }
            }
        }

        public UrlContext Url { get; set; }

        public MenuItemNode()
        {
            ChildNodes = new List<MenuItemNode>();
        }
    }
}
